package uumoi

class Collection {
	String name
	String description
	Date startDate
	Date endDate

	Channel channel
	Region region
	Brand brand
	Account account

   static hasMany = [products: Product]


   static constraints = {
	   description nullable: true
   }

	static findActiveCollections(Account a, Brand b, Region r, Channel c) {
		return where {
			if (b)
				brand == b
			if (r)
				region == r
			if (c)
				channel == c

			account == a

			startDate < new Date()
			endDate > new Date()
		}
	}

	static findFutureCollections(Account a, Brand b, Region r, Channel c) {
		return where {
			if (b)
				brand == b
			if (r)
				region == r
			if (c)
				channel == c

			account == a

			startDate > new Date()
			endDate > new Date()
		}
	}
}
